import json, sys, array
import datetime

if len(sys.argv) < 2:
    print "enter json file"
    sys.exit(0)
    
f = open(sys.argv[1]);
players = json.loads(f.read())

print "Number of players: %d" % len(players) 

totalPlayers = 0
returnPlayers = 0

levelsReturnedTo = array.array('I', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])

for player in players:
    
    prevDay = datetime.datetime(2012,6,01)
    returned = False
    curDay = datetime.datetime(2012,6,01)
    
    levels = player['levels']
    for level in levels:
        
        if curDay < datetime.datetime(2012,5,17):
            break
        
        if level['qid'] > 20:
            continue
            
        prevDay = curDay
        curDay = datetime.datetime.fromtimestamp(level['log_q_ts'])
        
        if (( curDay - prevDay).seconds >= 7200 and (curDay-prevDay).days == 0) or (curDay-prevDay).days > 0:
            returned = True
            while len(levelsReturnedTo) <= int (level['qid']):
                levelsReturnedTo.append(0)
            levelsReturnedTo[int(level['qid'])] += 1
    
    totalPlayers = totalPlayers + 1
    
    if returned:
        returnPlayers = returnPlayers + 1
            

print "%d,%d" % (returnPlayers,totalPlayers)

for i in range(0,21):
    print "%d,%d" % (i, (levelsReturnedTo[i] if len(levelsReturnedTo) > i else 0))